package org.example;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int n = s.length();
        int max = 0;
        for (int l = 0; l < n; l++) {
            for (int r = n - 1; r > l; r--) {
                if (s.charAt(l) != s.charAt(r)) {
                    max = Math.max(r - l + 1,max);
                    break;
                }
            }
        }
        System.out.println(max);
    }
}
